package com.four.dailymanage.office.controller;

import com.four.dailymanage.common.bean.ResponseData;
import com.four.dailymanage.common.controller.BaseController;
import com.four.dailymanage.office.dao.OfficeDao;
import com.four.dailymanage.office.entity.Office;
import com.four.dailymanage.office.service.OfficeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/office")
public class OfficeController extends BaseController {
    @Autowired
    OfficeService officeService;
    //分页
    @GetMapping("/getPage")
    public ResponseData<Object> getPage(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "handleMan",required = false) String handleMan,
            @RequestParam(value = "applyType",required = false) String applyType,
            @RequestParam(value = "examineStatus",required = false) String examineStatus
    ){
        return returnObject(officeService.getOfficeApply(pageNum, pageSize, handleMan,applyType, examineStatus));
    }
    //添加
    @PostMapping("/addOffice")
    public ResponseData<Object> insertOffice(@RequestBody Office office){
        return returnObject(officeService.add(office));
    }
    //审批管理  修改时间以及状态
    @PutMapping("/approve")
    public ResponseData<Boolean> updateApprove(@RequestBody Office office){
        return returnBoolean(officeService.approve(office));
    }

    @PutMapping("/reject")
    public ResponseData<Boolean> updateReject(@RequestBody Office office){
        return returnBoolean(officeService.reject(office));
    }
}
